// 2. 项目根目录创建 craco.config.js
const CracoLessPlugin = require('craco-less');
const path = require('path')
const vars = require('./src/styles/var.js')
module.exports = {
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            // 关键配置：自动注入全局变量文件
            additionalData: (content) => {
              return `@import "${path.resolve(__dirname, 'src/styles/common.less')}";${content}`;
            },
            modifyVars: vars,
            javascriptEnabled: true
          }
        }
      }
    }
  ],
  webpack: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      '#': path.resolve(__dirname, 'public')
    }
  },
};